﻿#ifndef DEVICESETTINGSTAB_H
#define DEVICESETTINGSTAB_H

#include <QWidget>
#include <QStandardItem>
#include "Base/Command.h"

namespace Ui {
class DeviceSettingsTab;
}

class DeviceSettingsTab : public QWidget
{
    Q_OBJECT

public:
    explicit DeviceSettingsTab(QWidget *parent = nullptr);
    ~DeviceSettingsTab();
    void drawGrid();
    void loadTableSub();
    void loadTablePort();
    void loadDeviceInfo();
    void loadTableUser();
    void freshTableUser(QList<QVariantList> allrecord);
    inline bool stringToint(QString str,int &value,int base);

signals:
    void sig_sendQRLocateCmd(QRLocateCommand);
    void sig_moveCmd(QString,int,int,QString);
    void sig_subConfigInsertDB(QList<QVariantList>);
    void sig_portConfigInsertDB(QList<QVariantList>);
    void sig_deviceConfigDB(QList<QVariantList>);
    void sig_goodsDistributeCalculate();
    void sig_userInfoInsertDB(QVariantList);
    void sig_getUserInfo();
    void sig_updateUserInfo(QVariantMap,QVariantMap);
    void sig_deleteUserInfo(QVariantMap);
private slots:
    void on_bt_startlocate_clicked();

    void on_btn_inoutcabnext_clicked();

    void on_btn_stop_clicked();

    void on_btn_subdelete_clicked();

    void on_btn_subedit_clicked();

    void on_btn_subsave_clicked();

    void on_btn_portsave_clicked();

    void on_btn_portadd_clicked();

    void on_btn_portdelete_clicked();

    void on_btn_portedit_clicked();

    void on_btn_creatable_clicked();
    void slot_storgeUIRefreshTable();

    void on_btn_creatgoods_clicked();

    void on_tb_sub_cellChanged(int row, int column);

    void on_btn_saveconfig_clicked();
    void on_btn_useradd1_clicked();

    void on_btn_pwdalter1_clicked();

    void on_bnt_adduser1_clicked();
    void slot_freshUserInfo(QList<QVariantList>);

    void on_btn_userlock_clicked();

    void on_btn_pwdalter2_clicked();

    void on_btn_userdelete_clicked();

private:
    Ui::DeviceSettingsTab *ui;
    QRLocateCommand lastcmd;
    QList<QList<QPoint>> mQRPoint;
    QStandardItemModel   model;
    QMap<int,QString> mRoleMap = {{-1,"超级管理员"},{0,"管理员"},{1,"普通用户"}};
    QMap<int,QString> mUserStateMap = {{0,"正常"},{1,"锁定"}};
    QList<QVariantList> mUserDate;  //存储用户数据，修改密码等

};

#endif // DEVICESETTINGSTAB_H
